//获取input
var inputs=document.getElementsByTagName('input');
//给input添加焦点离开事件
addEvent(inputs[0],'blur',function(){setValue(this,'用户名');});
addEvent(inputs[1],'blur',function(){setValue(this,'密码******');});
addEvent(inputs[5],'blur',function(){setValue(this,'用户名');});
addEvent(inputs[6],'blur',function(){setValue(this,'手机号码');});
addEvent(inputs[7],'blur',function(){setValue(this,'邮箱地址');});
addEvent(inputs[8],'blur',function(){setValue(this,'密码******');});
//给input添加焦点事件
addEvent(inputs[0],'focus',function(){clearValue(this,'用户名');});
addEvent(inputs[1],'focus',function(){clearValue(this,'密码******');});
addEvent(inputs[5],'focus',function(){clearValue(this,'用户名');});
addEvent(inputs[6],'focus',function(){clearValue(this,'手机号码');});
addEvent(inputs[7],'focus',function(){clearValue(this,'邮箱地址');});
addEvent(inputs[8],'focus',function(){clearValue(this,'密码******');});

function clearValue(obj,s){
	if (obj.value == s){obj.value = "";}
}
function setValue(obj,s){
	if (obj.value == ''){obj.value = s;}
}
function addEvent(obj,type,handle){
    try{  // Chrome、FireFox、Opera、Safari、IE9.0及其以上版本
        obj.addEventListener(type,handle,false);
    }catch(e){
        try{  // IE8.0及其以下版本
            obj.attachEvent('on' + type,handle);
        }catch(e){  // 早期浏览器
            obj['on' + type] = handle;
        }
    }
}


//创建动画
var content1=document.getElementsByClassName("content1")[0];//登陆页面
var content2=document.getElementsByClassName("content2")[0];//注册页面
//登陆界面离开，注册界面显示
addEvent(document.getElementById("zuce"),'click',function (){
	if(!content2.classList.contains("anout")){
		content1.classList.toggle("anout");
		content2.classList.toggle("anin");
		content2.classList.toggle("hidden");
	setTimeout(function(){
		content1.classList.toggle("hidden");
		content1.classList.toggle("anout");
		content2.classList.toggle("anin");
	},2000);
	}
});
//注册界面离开，登陆界面显示
addEvent(document.getElementById("login"),'click',function (){
	if(!content1.classList.contains("anout")){
		content2.classList.toggle("anout");
		content1.classList.toggle("anin");
		content1.classList.toggle("hidden");
	setTimeout(function(){
		content2.classList.toggle("hidden");
		content2.classList.toggle("anout");
		content1.classList.toggle("anin");
	},2000);
	}
});



